/**
 * 
 */
package org.optimus.dao;

import java.io.Serializable;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.optimus.beans.Persona;
import org.optimus.utils.MyBatisUtil;

/**
 * @author juan.roman
 *
 */
public class PersonaDAO implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private SqlSessionFactory sqlSessionFactory;
	
	public PersonaDAO(){
		sqlSessionFactory = new MyBatisUtil().getSqlSessionFactory();
	}
	
	
	public Persona buscarPorId(Integer id){
		SqlSession session = sqlSessionFactory.openSession();
		try {
			Persona persona = session.selectOne("Persona.buscarPorId",id);
			return persona;
		} catch (Exception e) {
			System.out.println(" Error en PersonaDAO > buscarPorId : " + e.getMessage());
			return null;
		}finally{
			session.close();
		}
	}
	

}
